/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Validations;


import Services.exception.ServiceException;
import Services.UserServices;
import beans.UserBean;

/**
 *
 * @author Anthar
 */
public class UserValidation {

    private UserServices userService;

    public UserValidation(){
        userService = new UserServices();
    }



   public boolean isValidTransferAmountOperation(double actualUserAmount, double transferAmount){
          return enoughtAmountToTransfer(actualUserAmount, transferAmount);
   }

   private boolean enoughtAmountToTransfer(double actualAmount, double transferAmount) {
       if(actualAmount >= transferAmount){
            return true;}
       return false;
   }

   public boolean validTypeUser(int userLevel){
        if(userLevel>=UserLevel.ADMINISTRATOR && userLevel<=UserLevel.CLIENT){
           return true;
        }
        return false;
        
   }

   public boolean existUserAccount(String userAccountName) throws ServiceException {
       UserBean user = getUserService().searchUser(userAccountName);
        if(user!= null){
            return true;
        }
        return false;
     }
   
    public boolean isCoincidenceAccount(String actualAccount ,UserBean userInfo) {
        return actualAccount.equals(userInfo.getUserAccountName());
  }

   /*********************
    * GETTERS Y SETTERS
    ********************/

    /**
     * @return the userService
     */
    public UserServices getUserService() {
        return userService;
    }

    /**
     * @param userService the userService to set
     */
    public void setUserService(UserServices userService) {
        this.userService = userService;
    }



}
